﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HFController;
using System.Web.SessionState;
using System.Web.Script.Serialization;
namespace HFWebApp.AjaxSource
{
    /// <summary>
    /// AddAsk 的摘要说明
    /// </summary>
    public class AddAsk : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            BagePages bp = new BagePages();
            context.Response.ContentType = "text/plain";
            string title = bp.GetAll("title");
            string content = bp.GetAll("content");
            string provinceid = bp.GetAll("provinceid");
            string cityid = bp.GetAll("cityid");
            string classid = bp.GetAll("classid");
            string smallclassid = bp.GetAll("smallclassid");
            string points = bp.GetAll("points");

            HFModel.ResultModel result = AskController.getController().doAddAsk(title, int.Parse(classid), int.Parse(smallclassid), content, int.Parse(points), int.Parse(provinceid), int.Parse(cityid));

            context.Response.Write(this.getJSONResult(result));
            context.Response.End();
        }

        protected string getJSONResult(HFModel.ResultModel result)
        {
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer(new SimpleTypeResolver());
            return jsSerializer.Serialize(result);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}